package com.gaofeng.day20;

public class demo01 {
    public static void main(String[] args) {
        int[] arr = {1,2,3,4,5,6,7,8};
        int sum = getSum(arr);
        System.out.println(sum);

        int sum2 = getSum2(1, 2, 3, 4, 5, 6, 7, 8);
        System.out.println(sum2);
    }

    public static int getSum(int[] arr){
        int sum = 0;
        for (int i : arr) {
            sum += i;
        }
        return sum;
    }

    public static int getSum2(int...args){
        int sum = 0;
        for (int arg : args) {
            sum += arg;
        }
        return sum;
    }
}
